﻿using System.Windows;
using System.Windows.Controls;
using Shoozla.DataModel.Helper;
using Shoozla.DataModel;
using MahApps.Metro.Controls;
using Shoozla.ViewModel;


namespace Shoozla.View
{
    /// <summary>
    /// Interaction logic for SearchAddinView.xaml
    /// </summary>
    public partial class SearchAddinView : MetroWindow
    {

        public SearchAddinView()
        {
            InitializeComponent();       
        }

        public SearchAddinView(int count) : this()
        {
            DataContext = new SearchAddInViewModel(count,this,App.MainView);
            //we have at least 1 one (application constraint)
            addInCB.SelectedIndex = 0;
        }

        private void continueBT_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }

        private void cancelBT_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        private void addInCB_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CoverSearcher cs = e.AddedItems[0] as CoverSearcher;
            if (cs != null)
            {
                addinDescLB.Content = cs.AddInDescription;
                addinDescLB.Visibility = System.Windows.Visibility.Visible;
                AppModel.CoverSearcher = cs;
            }
        }
    }
}
